package cn.wolfcode.edu.web.controller;

import cn.wolfcode.edu.domain.ClientTrace;
import cn.wolfcode.edu.query.QueryObject;
import cn.wolfcode.edu.service.IClientTraceService;
import cn.wolfcode.edu.util.JsonResult;
import cn.wolfcode.edu.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("clienttrace")
public class ClientTraceController {

    @Autowired
    private IClientTraceService clientTraceService;

    //定位潜在客户跟进页面
    @RequestMapping("")
    public String goToClientTracePage(){
        return "/client/clientTrace";
    }

    //列出所有潜在客户跟进数据
    @RequestMapping("list")
    @ResponseBody
    public PageResult list(QueryObject qo){
        PageResult pageResult = clientTraceService.query(qo);
        return pageResult;
    }


    //新增用户列表
    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(ClientTrace clientTrace){
        try {
            clientTraceService.save(clientTrace);
            return new JsonResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("新增失败");
        }
    }

    //跟进审核
    @RequestMapping("audit")
    @ResponseBody
    public JsonResult audit(ClientTrace clientTrace){
        try {
            clientTraceService.audit(clientTrace);
            return new JsonResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult("新增失败");
        }
    }

}

